package kr.co.mustgo.model.dao.reservation;

import java.sql.SQLException;
import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import kr.co.mustgo.domain.reservation.Reservation;

@Repository
public class ReservationDAOImpl implements ReservationDAO{
	
	@Autowired
	private SqlSessionTemplate session;
	
	@Override
	public Reservation selectProductInfo(Reservation reservation)
			throws SQLException {
		return (Reservation) session.selectList(makeSqlReserveCode("searchProductInfo"), reservation);
	}

	@Override
	public Reservation selectReserveInfo(Reservation reservation)
			throws SQLException {
		return (Reservation) session.selectList(makeSqlReserveCode("searchReserveInfo"),reservation);
	}

	@Override
	public int insertReserverInfo(Reservation reservation)
			throws SQLException {
		return session.insert(makeSqlReserveCode("insertReserverInfo"),reservation);
	}
	
	@Override
	public List<Reservation> selectReservation(Reservation reservation)
			throws SQLException {
		return session.selectList(makeSqlReserveCode("searchReservation"));
	}

	@Override
	public int updateReservation(Reservation reservation)
			throws SQLException {
		return session.update(makeSqlReserveCode("updateReservation"));
	}

	@Override
	public int deleteReservation(Reservation reservation)
			throws SQLException {
		return session.delete(makeSqlReserveCode("deleteReservation"));
	}

	private String makeSqlReserveCode(String reserveCode){
		return "예약 DAO"+reserveCode;
	}
}
